Skip to main content

is a

Type

operator

Summary

Evaluates to true if a value is of the specified type, false otherwise.

Syntax

<value> is a[n] {array | [numeric] sequence | boolean | color | date | integer | number | point | rect | ASCII string }

Description

Use the is a operator to validate data to make sure it's the right type.

This operator is useful for checking whether the user has entered data correctly, and for checking parameters before sending them to a handler to avoid a script error caused by feeding data of one type to an operator or function that requires a different type.

A value is a(n):

  • array if its keys function is not empty.
  • sequence if its keys function is not empty and has N integer keys spanning 1 to N.
  • numeric sequence if its keys function is not empty and has N integer keys spanning X to Y
  • boolean or logical if it is one of the two constants true or false
  • color if it is a valid < color reference:::note[ date if it is in one of the formats produced by the date or time functions ]

number if it is a result of a numeric operation, or a string representing a decimal number (e.g. 100.01 or -10), a hexadecimal number (e.g. 0x1FB) or a number in scientific notation (e.g. 100.001e-10).

  • integer if it is a number and the number has no (non-zero) fractional part (e.g. 100.000 is an integer, but 100.001 is not an integer).
  • point if it consists of two numbers separated by a comma
  • rect if it consists of four numbers separated by commas
  • ASCII string if it does not contain any characters greater than charToNum(127)

:::

All the types other than boolean can also include leading or trailing white space characters.

note

The range of dates that LiveCode can handle is limited by the operating system's date routines. In particular, Windows systems are limited to dates after 1/1/1970. This means that the is a date operator will return false for dates before 1/1/1970 on Windows.

The is a operator is the logical inverse of the is not a operator. When one is true, the other is false.

Parameters

NameTypeDescription

value

Any source of value.

Examples

"1/16/98" is a date -- evaluates to true
1 is a boolean -- evaluates to false
45.4 is an integer -- evaluates to false
"red" is a color -- evaluates to true
local tArray
put "test" into tArray[1]
put tArray is an array -- evaluates to true
numToChar(128) is an ASCII string -- evaluates to false

command: convert

function: colorNames, date, isNumber, keys, time

glossary: array, ASCII, boolean, color reference, evaluate, integer, inverse, logical, operator, string, validate, value

keyword: array, integer, point, rectangle

operator: is not a, as a

Compatibility and Support

Introduced

LiveCode 1.0

OS

mac

windows

linux

ios

android

Platforms

desktop

server

mobile

Thank you for your feedback!

Was this page helpful?